package com.lili.setting.controller;

import com.lili.common.result.Result;
import com.lili.model.setting.Role;
import com.lili.model.setting.RoleMenu;
import com.lili.setting.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/admin/setting/role")
public class RoleController {

    @Autowired
    private RoleService roleService;


    /**
     * 添加角色权限
     *
     * @param role
     * @return
     */
    @PostMapping("/save")
    public Result saveRole(@RequestBody Role role) {

        roleService.saveRole(role);

        return Result.ok();
    }


    /**
     * 给角色添加权限
     *
     * @return
     */
    @PostMapping("/roleAuth/{roleId}")
    public Result setRoleAuth(@PathVariable String roleId, @RequestBody List<RoleMenu> list) {

        roleService.setRoleAuth(roleId, list);

        return Result.ok();
    }


}
